package role

import (
	"gitee.com/binny_w/gin_starter/core"
	"gitee.com/binny_w/go-util"
)

func All() ([]string, error) {
	roles, err := core.Cache.GetOrSingleDo("all-role", func(k string, mc *util.MemCache) (any, error) {
		roles, err := core.Rbac.GetAllRoles()
		if err != nil {
			return nil, err
		}
		mc.Set(k, roles, 30)
		return roles, nil
	})
	return roles.([]string), err
}
